<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>申请表管理</title>
    <link rel="stylesheet" href="../../../lib/layui-v2.5.5/css/layui.css" media="all">
    <link rel="stylesheet" href="../../../css/public.css" media="all">
</head>
<body>


<div class="layuimini-container">
    <div class="layuimini-main">

        <div class="layui-form-item">
            <label class="layui-form-label">患者id:</label>
            <div class="layui-input-inline">
                <input type="text" name="pid" placeholder="请输入" autocomplete="off" class="layui-input" id="pid" value="1">
            </div>
            <label class="layui-form-label">医生id:</label>
            <div class="layui-input-inline">
                <input type="text" name="did" placeholder="请输入" autocomplete="off" class="layui-input" id="did" value="1">
            </div>
            <div class="layui-input-inline">
                <button type="submit" class="layui-btn layui-btn-primary" lay-submit  lay-filter="data-search-btn"><i class="layui-icon"></i> 搜 索</button>
            </div>
        </div>


        <div class="layui-btn-container">
            <button class="layui-btn layui-btn-sm layui-btn-danger data-update-btn"> 审批申请表 </button>

        </div>
        <div>查看未审批申请表</div>
        <table class="layui-hide" id="currentTableId" lay-filter="currentTableFilter">
        </table>
        <div>查看未通过申请表</div>
        <table class="layui-hide" id="currentTableIdd" lay-filter="currentTableFilter">
        </table>
        <div>查看已审批申请表</div>
        <table class="layui-hide" id="currentTableIddd" lay-filter="currentTableFilter">
        </table>
    </div>
</div>

<script src="../../../lib/layui-v2.5.5/layui.js" charset="utf-8"></script>
<script src="../../../js/lay-config.js?v=1.0.4" charset="utf-8"></script>
<script>
    layui.use(['table', 'form', 'tableSelect'], function () {
        var $ = layui.jquery,
            table = layui.table,
            form = layui.form,
            tableSelect = layui.tableSelect;


    layui.use(['table', 'form'], function () {
        //开始使用

        var $ = layui.jquery,
            form = layui.form,
            table = layui.table,
            layuimini = layui.layuimini;


        var userInfo = layui.data('userInfo');

        //加载信息
        table.render({
            elem: '#currentTableId',
            url: 'http://localhost:8080/application/findAllapplication',
            toolbar: '#toolbarDemo',
            defaultToolbar: ['filter', 'exports', 'print', {
                title: '提示',
                layEvent: 'LAYTABLE_TIPS',
                icon: 'layui-icon-tips'
            }],
            cols: [[
                {field: 'aid', width: 80, title: '申请表编号'},
                {field: 'mid', width: 120, title: '药品编号'},
                {field: 'mname', width: 80, title: '药品姓名'},
                {field: 'pid', width: 120, title: '病人编号'},
                {field: 'pname', width: 90, title: '病人姓名'},
                {field: 'did', width: 140, title: '医生编号'},
                {field: 'dname', width: 100, title: '医生姓名'},
                {field: 'aremark', width: 100, title: '申请备注'},
                {field: 'meid', width: 100, title: '器材编号'},
                {field: 'mename', width: 100, title: '器材名称'},
                {field: 'result', width: 100, title: '审批结果'},
            ]],
            limits: [10, 15, 20, 25, 50, 100],
            limit: 15,
            page: true,
            done: function (res, page, count) {
                //如果是异步请求数据方式，res即为你接口返回的信息。
                //如果是直接赋值的方式，res即为：{data: [], count: 99} data为当前页数据、count为数据总长度
                //分类显示中文名称
                $("[data-field='result']").children().each(function () {
                    if ($(this).text() === '0') {
                        $(this).text("未审批")
                    } else if ($(this).text() === '1') {
                        $(this).text("通过")
                    }else if ($(this).text() === '2') {
                        $(this).text("不通过")
                    }
                });

            }
        });


        //加载信息
        table.render({
            elem: '#currentTableIdd',
            url: 'http://localhost:8080/application/findAllapplicationno',
            toolbar: '#toolbarDemo',
            defaultToolbar: ['filter', 'exports', 'print', {
                title: '提示',
                layEvent: 'LAYTABLE_TIPS',
                icon: 'layui-icon-tips'
            }],
            cols: [[
                {field: 'aid', width: 80, title: '申请表编号'},
                {field: 'mid', width: 120, title: '药品编号'},
                {field: 'mname', width: 80, title: '药品姓名'},
                {field: 'pid', width: 120, title: '病人编号'},
                {field: 'pname', width: 90, title: '病人姓名'},
                {field: 'did', width: 140, title: '医生编号'},
                {field: 'dname', width: 100, title: '医生姓名'},
                {field: 'aremark', width: 100, title: '申请备注'},
                {field: 'meid', width: 100, title: '器材编号'},
                {field: 'mename', width: 100, title: '器材名称'},
                {field: 'result', width: 100, title: '审批结果'},
            ]],
            limits: [10, 15, 20, 25, 50, 100],
            limit: 15,
            page: true,
            done: function (res, page, count) {
                //如果是异步请求数据方式，res即为你接口返回的信息。
                //如果是直接赋值的方式，res即为：{data: [], count: 99} data为当前页数据、count为数据总长度
                //分类显示中文名称
                $("[data-field='result']").children().each(function () {
                    if ($(this).text() === '0') {
                        $(this).text("未审批")
                    } else if ($(this).text() === '1') {
                        $(this).text("通过")
                    }else if ($(this).text() === '2') {
                        $(this).text("不通过")
                    }
                });

            }
        });


        //加载信息
        table.render({
            elem: '#currentTableIddd',
            url: 'http://localhost:8080/application/findAllapplicationyes',
            toolbar: '#toolbarDemo',
            defaultToolbar: ['filter', 'exports', 'print', {
                title: '提示',
                layEvent: 'LAYTABLE_TIPS',
                icon: 'layui-icon-tips'
            }],
            cols: [[
                {field: 'aid', width: 80, title: '申请表编号'},
                {field: 'mid', width: 120, title: '药品编号'},
                {field: 'mname', width: 80, title: '药品姓名'},
                {field: 'pid', width: 120, title: '病人编号'},
                {field: 'pname', width: 90, title: '病人姓名'},
                {field: 'did', width: 140, title: '医生编号'},
                {field: 'dname', width: 100, title: '医生姓名'},
                {field: 'aremark', width: 100, title: '申请备注'},
                {field: 'meid', width: 100, title: '器材编号'},
                {field: 'mename', width: 100, title: '器材名称'},
                {field: 'result', width: 100, title: '审批结果'},
            ]],
            limits: [10, 15, 20, 25, 50, 100],
            limit: 15,
            page: true,
            done: function (res, page, count) {
                //如果是异步请求数据方式，res即为你接口返回的信息。
                //如果是直接赋值的方式，res即为：{data: [], count: 99} data为当前页数据、count为数据总长度
                //分类显示中文名称
                $("[data-field='result']").children().each(function () {
                    if ($(this).text() === '0') {
                        $(this).text("未审批")
                    } else if ($(this).text() === '1') {
                        $(this).text("通过")
                    }else if ($(this).text() === '2') {
                        $(this).text("不通过")
                    }
                });

            }
        });



        // 监听添加操作
        $(".data-add-btn").on("click", function () {

            var index = layer.open({
                title: '添加器材',
                type: 2,
                shade: 0.2,
                maxmin:true,
                shadeClose: true,
                area: ['100%', '100%'],
                content: './operation/add_cur.html',
            });
            $(window).on("resize", function () {
                layer.full(index);
            });
            return false;
        });

        // 监听修改操作
        $(".data-update-btn").on("click", function () {

            var index = layer.open({
                title: '修改器材',
                type: 2,
                shade: 0.2,
                maxmin:true,
                shadeClose: true,
                area: ['100%', '100%'],
                content: './operation/update_cur.html',
            });
            $(window).on("resize", function () {
                layer.full(index);
            });

            return false;
        });
    });



        // 监听搜索操作
        form.on('submit(data-search-btn)', function (data) {
            var field = data.field;
            //执行搜索重载
            table.reload('currentTableId', {
                page: {
                    curr: 1
                }
                , where: {
                    pid: $('#pid').val(),
                    did: $('#did').val(),
                }//这里传参  向后台
                , url: 'http://localhost:8080/application/searchD'
                , method: 'get'
            }, 'data');
            return false;
        });

    });
</script>
</body>
</html>